import type { RuleItem, AddRuleParamsType, RuleListData, RuleListParams } from "@/types/carRule"
import { myGet, myPost, myRequest } from "@/utils/reuqest"

// 获取规则列表API
export const getRuleListAPI = (params: RuleListParams) => {
    return myGet<RuleListData>('/parking/rule/list', params)
}

// 添加规则API
export const addRuleAPI = (data: AddRuleParamsType) => {
    return myPost('/parking/rule', data)
}

// 查看规则API
export const watchRuleAPI = (id: string) => {
    return myGet<AddRuleParamsType & { id: number }>(`/parking/rule/${id}`)
}

// 修改规则API
export const editRuleAPI = (data: AddRuleParamsType & { id: number }) => {
    return myRequest({
        url: '/parking/rule',
        method: 'PUT',
        data
    })
}

// 删除规则API
export const deleteRuleAPI = (id: string) => {
    return myRequest({
        url: `/parking/rule/${id}`,
        method: 'DELETE'
    })
}